package com.wwg.market.ui.service.interfaces;

import com.nexustar.gwt.widgets.client.model.PaginationModelDto;
import com.wwg.market.ui.service.dto.GeneralCodeDto;
import com.wwg.market.ui.service.dto.member.MemberDto;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 *
 * @author gaoyang
 * @version $Id: $
 * @date 12-2-27 上午1:30
 */
public class MemberServiceImpl implements MemberService {
    public List<MemberDto> getMemberList(Map map) {
        System.out.println("query map = " + map);
        List<MemberDto> list = new ArrayList<MemberDto>();
        for (int i = 0; i < 8; i++) {
            MemberDto dto = new MemberDto();
            dto.setBalance(Double.valueOf(i));
            GeneralCodeDto city = new GeneralCodeDto();
            city.setName("city" + i);
            dto.setCity(city);
            dto.setCreator("creator" + i);
            dto.setEmail("email" + i);
//            dto.setGender();
            dto.setLastLoginTime(new Date());
//            dto.setLevel();
            dto.setLocked((int) (Math.random() * 2) == 0);
            dto.setLoginCount(i);
            dto.setName("name" + i);
            dto.setPassword("pwd" + i);
            dto.setPhone("2222" + i);
            dto.setQq("111" + i);
            dto.setRegisterIP("192.168.1." + i);
            dto.setRegisterTime(new Date());
            dto.setPoint(i);
            dto.setUsername("username" + i);
            dto.setLastLoginTime(new Date());
            list.add(dto);
        }
        return list;
    }

    public PaginationModelDto<MemberDto> getMemberList(Integer begin, Integer count, Map<String, String> conditions) {
        System.out.println("begin = " + begin);
        System.out.println("count = " + count);
        System.out.println("conditions = " + conditions);
        PaginationModelDto<MemberDto> paginationModelDto = new PaginationModelDto<MemberDto>();
        List list = new ArrayList<MemberDto>();
        for (int i = begin; i < begin + count; i++) {
            MemberDto dto = new MemberDto();
            dto.setBalance(Double.valueOf(i));
            GeneralCodeDto city = new GeneralCodeDto();
            city.setName("city" + i);
            dto.setCity(city);
            dto.setCreator("creator" + i);
            dto.setEmail("email" + i);
//            dto.setGender();
            dto.setLastLoginTime(new Date());
//            dto.setLevel();
            dto.setLocked((int) (Math.random() * 2) == 0);
            dto.setLoginCount(i);
            String username = conditions.get("username");
            username = username == null ? "username" : username;
            username += i;
            dto.setName("姓名" + i);
            dto.setPassword("pwd" + i);
            dto.setPhone("2222" + i);
            dto.setQq("111" + i);
            dto.setRegisterIP("192.168.1." + i);
            dto.setRegisterTime(new Date());
            dto.setPoint(i);
            dto.setUsername(username);
            dto.setLastLoginTime(new Date());
            list.add(dto);
        }
        paginationModelDto.setTotalRecord(100);
        paginationModelDto.setModelData(list);
        return paginationModelDto;
    }

    public MemberDto createMember(MemberDto dto) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    public MemberDto updateMember(MemberDto dto) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    public void deleteMember(MemberDto dto) {
        //To change body of implemented methods use File | Settings | File Templates.
    }
}
